// pages/regist/regist.js
var app = getApp(); //获取应用实例
const quote = app.globalData.quote;
const mta = quote.mta;
const util = quote.util;
const tools = quote.tools;
const api = quote.api;
const path = quote.paths;
const LoginRegist = quote.LoginRegist;

Page({

    /**
     * 页面的初始数据
     */
    data: {
        path: path,
        getCode_ing: false,
        remainTime: 0,
        Name: "",
        Phone: "",
        Pwd: "",
        Phonecode: "",
        hiddenName: true,
        hiddenPhone: true,
        hiddenPwd: true,
        hiddenPhonecode: true,
        nickName: null,
        fromPage: "",
        verification: '',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;

        console.log('打开得注册获取到的数据', options)
        console.log(app.globalData.userInfo)

        this.setData({
            nickName: app.globalData.userInfo != null ? app.globalData.userInfo.nickName : "请输入用户名",
            name: app.globalData.userInfo != null ? app.globalData.userInfo.nickName : "请输入用户名",
            fromPage: options.fromPage || "",
        })

    },
    onReady: function(options) {
        var that = this;

        mta.Page.init();
        LoginRegist.addParam(that, app, api, path, mta)

    },

    bindInput: function(e) {

        LoginRegist.bindInput(e)
    },

    tapGetAuthCode: function(e) {

        LoginRegist.tapGetAuthCode(e)
    },

    aldClickLogin: function() {
        app.aldstat.sendEvent('注册-点击去登陆', {
            '微信openid': app.globalData.openId,
        });
        mta.Event.stat("register_clicklogin", { 'openid': app.globalData.openId, })
    },

    getAuthCode: function() {
        var self = this;

        app.aldstat.sendEvent('注册-点击发送验证码', {
            '微信openid': app.globalData.openId,
        });
        mta.Event.stat("register_sendverificationcode", { 'openid': app.globalData.openId, })

        LoginRegist.getAuthCode()
    },


    tapRegist: function(e) {
        var self = this;

        app.aldstat.sendEvent('注册-点击注册', {
            '微信openid': app.globalData.openId,
        });
        mta.Event.stat("register_clickregister", { 'openid': app.globalData.openId, 'source': app.globalData.appSource })

        LoginRegist.regist(function() {
            console.log('注册成功');
            app.aldstat.sendEvent('注册-注册成功', {
                '微信openid': app.globalData.openId,
            });
            mta.Event.stat("register_clickregistersuccess", { 'openid': app.globalData.openId, 'source': app.globalData.appSource });
        });
    },


    bindblur: function(e) {

        LoginRegist.bindblur(e)
    },

    bindfocus: function(e) {

        LoginRegist.bindfocus(e)
    },
})